package com.feng.servicebase.excecption;


import com.feng.commonutils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public R error(Exception e){
        e.printStackTrace();
        return R.error().message("系统忙,请稍后再试...");
    }
    @ExceptionHandler(ArithmeticException.class)
    public R error(ArithmeticException e){
        e.printStackTrace();
        return R.error().message("执行了ArithmeticException异常处理");
    }
    @ExceptionHandler(GuliException.class)
    public R error(GuliException e){
        e.printStackTrace();
        log.error(e.getMessage() );
        return R.error().setCode(e.getCode()).setMessage(e.getMsg());
    }
}
